//有序数组的二分查找
import java.util.Scanner;
public class Find {
    public static int find(int[]arr,int data){
        int left=0;
        int right=arr.length-1;
        while(left<=right)
        {
            int mid=(left+right)/2;
            if(data<arr[mid])
            {
                right=mid-1;
            }
            else if(data>arr[mid])
            {
                left=mid+1;
            }
            else
            {

                return mid;
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        int[]arr={1,5,7,9,11,13};
        System.out.println("请输入要查找的数：");
        Scanner sc=new Scanner(System.in);
        int data= sc.nextInt();
        int mid=find(arr,data);
        if(mid>=0)
        {
            System.out.println("找到了");
        }else{
            System.out.println("没找到！");
        }

        sc.close();
    }
}





